$(document).ready(function() {
	provinceInfo.baseURL = baseURL;
	provinceInfo.divId = "test";
	provinceInfo.init();
	provinceInfo.bindEvent();
	$("#form-add").find('tr td:first-child').css('font-weight','bold');
	$("#form-add").find('tr td:nth-child(3)').css('font-weight','bold');
	$("#form-add").Validform({
		tiptype : 1,
		showAllError:true,
		datatype: {
			"empty": /^\s*$/,
			"code":/^[a-z0-9A-Z_-]{2,16}$/,
			"money" : /^[0-9]\d{0,5}$/
				},
		callback : function(form) {
			layer.confirm('您确定要提交表单吗',function(){
				try{
					submit();
					}catch(e){
						layer.msg(e);
					}
					})
						return false;
					}
	

});
submit = function(){
	var data = {};
	data.name = $('#name').val();
	data.provinceCode = $('#_province').attr('name');
	data.cityCode = $('#_city').attr('name');
	data.districtCode = $('#_town').attr('name');
	data.provinceName=$('#_province').val();
	data.cityName=$('#_city').val();
	data.districtName=$('#_town').val();
	data.districtCode = data.districtCode==null?data.cityCode:data.districtCode;
	data.shortName = $('#shortname').val();
	data.licNum = $('#licnum').val();
	data.liceTime = $('#licetime').val();
	data.business = $('#business').val();
	data.creditCode = $('#creditcode').val();
	data.code =$('#inscode').val();
	data.legal = $('#legal').val();
	data.contact = $('#contact').val();
	data.phone=$('#phone').val();
	data.address=$('#address').val();
	data.postCode=$('#postcode').val();
	console.log(data)
	function busisCope(){
		var busisCopeValue=[];
		var busisCopeInput=$('#busiscope').find("input:checked");
		for(i=0;i<busisCopeInput.length;i++){
			busisCopeValue.push($(busisCopeInput[i]).val());
		}
		return busisCopeValue.toString();
	}
	$.ajax({
		type : "post",
		url : baseURL + '/api/organization/add',
		dataType : "json",
		timeout : 30000,
		contentType : "application/json",
		data : JSON.stringify(data),
		success : function(result) {
			if (!result.flag) {
				layer.msg("新增失败！原因：" + result.message);
				return false;
			}
			layer.closeAll();
			window.parent.location.reload();
		}
	}); 
 }
})
